// this is a reference (uniform of type int1) to the texture unit to use to draw this texture 
// (i.e. if only 1 texture assigned use 0) 
uniform sampler2D sceneTexture;

const	float	OFFSET_DELTA = 0.002;

void main() {
	
	vec2		offsetArray[9];
	offsetArray[0] = vec2(-OFFSET_DELTA, -OFFSET_DELTA);
	offsetArray[1] = vec2(0.0, -OFFSET_DELTA);	
	offsetArray[2] = vec2(OFFSET_DELTA, -OFFSET_DELTA);	
	
	offsetArray[3] = vec2(-OFFSET_DELTA, 0.0);
	offsetArray[4] = vec2(0.0, 0.0);	
	offsetArray[5] = vec2(OFFSET_DELTA, 0.0);	
	
	offsetArray[6] = vec2(-OFFSET_DELTA, OFFSET_DELTA);
	offsetArray[7] = vec2(0.0, OFFSET_DELTA);	
	offsetArray[8] = vec2(OFFSET_DELTA, OFFSET_DELTA);	
	
	vec4	sample[9];
	
	for(int i = 0; i < 9; i++) {
		sample[i] = texture2D(sceneTexture, gl_TexCoord[0].st + offsetArray[i]);
	}	
	
	vec4	textureColour = vec4((sample[0] + sample[1] + sample[2] +
							sample[3] + sample[4] + sample[5] +
							sample[6] + sample[7] + sample[8]) / 9.0);
	
	// assign the fragment colour to this texture colour
	gl_FragColor = vec4(textureColour);
}
